package com.ycfmedical.bed.present;

import com.ycfmedical.bed.R;
import com.ycfmedical.bed.bean.ImUser;
import com.ycfmedical.bed.local.DataManager;
import com.ycfmedical.bed.local.dao.UserDao;
import com.ycfmedical.bed.local.entity.User;
import com.ycfmedical.bed.ui.HomeActivity;
import com.ycfmedical.bed.utils.ResourceUtil;

import java.util.ArrayList;
import java.util.List;

import cn.droidlover.xdroidmvp.kit.Kits;
import cn.droidlover.xdroidmvp.mvp.XPresent;
import rx.Observable;

/**
 * Created by Egoist on 2017/3/14.
 */

public class HomePresenter extends XPresent<HomeActivity>
{

    // 从数据库获取数据
    public void loadData()
    {
        List<User> userList = UserDao.getAllUserInfoList();
        if (!Kits.Empty.check(userList))
        {
            DataManager.getInstance().setUser(userList.get(2));
            for (User user : userList)
            {
                if (user.getImAccount().equals(ImUser.getInstance().getImAccount()))
                {
                    DataManager.getInstance().setUser(user);
                    User user1 = DataManager.getInstance().getUser();

                }
            }
        }
        else
        {

            getV().getvDelegate().toastShort(ResourceUtil.getContext().getString(R.string.db_date_error)+"用户");
        }
    }

}
